list

type list<T> : collection<T>

Represents a mutable array list.

Since

0.6.0

Constructors

Link copied to clipboard
pure constructor()

Constructor for an empty list.

pure constructor(values: iterable<-T>)

Constructor for a list initialized with values from an iterable.

Functions

Link copied to clipboard
(alias) function _set(index: integer, value: T): T

Sets the element at the specified index. Fails if the provided index is out of bounds.

Alias
Link copied to clipboard
(alias) function _sort()

Sorts the list in place.

Alias
Link copied to clipboard
function add(value: T): boolean

Adds an element to the collection.

function add(index: integer, value: T): boolean

Inserts a value at the specified index. Fails if the provided index is out of bounds.

Link copied to clipboard
function add_all(values: collection<-T>): boolean

Adds all elements from another collection to this collection.

function add_all(index: integer, values: collection<-T>): boolean

Inserts all elements from a collection at the specified index. Fails if the specified index is out of bounds.

Link copied to clipboard
(alias) function addAll(values: collection<-T>): boolean

Adds all elements from another collection to this collection.

Alias
(alias) function addAll(index: integer, values: collection<-T>): boolean

Inserts all elements from a collection at the specified index. Fails if the specified index is out of bounds.

Alias
Link copied to clipboard
function clear()

Clears the collection.

Link copied to clipboard
pure function contains(value: T): boolean

Checks if the collection contains a specific element.

Link copied to clipboard
pure function contains_all(values: collection<-T>): boolean

Checks if the collection contains all elements of another collection.

Link copied to clipboard
(alias) pure function containsAll(values: collection<-T>): boolean

Checks if the collection contains all elements of another collection.

Link copied to clipboard
pure function empty(): boolean

Checks if the collection is empty.

Link copied to clipboard
pure function get(index: integer): T

Gets the element at the specified index. Fails if provided index is out of bounds.

Link copied to clipboard
pure function index_of(value: T): integer

Gets the index of the first occurrence of a value in the list, or -1 if not found.

Link copied to clipboard
(alias) pure function indexOf(value: T): integer

Gets the index of the first occurrence of a value in the list, or -1 if not found.

Alias
Link copied to clipboard
pure function join_to_text([separator: text], [prefix: text], [postfix: text], [limit: integer?], [truncated: text], [transform: (T) -> text]): text

Creates a text from all the elements separated using separator and using the given prefix and postfix if supplied.

If the iterable is large, you can specify a non-negative value of limit, in which case only the first limit of elements will be appended, followed by the truncated text (which defaults to "...").

Link copied to clipboard
(alias) pure function len(): integer

Returns the size of the collection.

Alias
Link copied to clipboard
function remove(value: T): boolean

Removes an element from the collection.

Link copied to clipboard
function remove_all(values: collection<-T>): boolean

Removes all elements from the collection that are present in another collection.

Link copied to clipboard
function remove_at(index: integer): T

Removes and returns the element at the specified index. Fails if provided index is out of bounds.

Link copied to clipboard
(alias) function removeAll(values: collection<-T>): boolean

Removes all elements from the collection that are present in another collection.

Link copied to clipboard
(alias) function removeAt(index: integer): T

Removes and returns the element at the specified index. Fails if provided index is out of bounds.

Alias
Link copied to clipboard
function repeat(n: integer): list<T>

Returns a new list with the elements from this list repeated a specified number of times.

Link copied to clipboard
function reverse()

Reverses the order of elements in the list in place.

Link copied to clipboard
function reversed(): list<T>

Gets a new list with elements in reversed order.

Link copied to clipboard
function set(index: integer, value: T): T

Sets the element at the specified index. Fails if the provided index is out of bounds.

Link copied to clipboard
pure function size(): integer

Returns the size of the collection.

Link copied to clipboard
function sort()

Sorts the list in place.

Link copied to clipboard
pure function sorted(): list<T>

Returns a new sorted list of elements from the collection.

Link copied to clipboard
(alias) pure function str(): text

Converts the collection to a text representation.

Alias
Link copied to clipboard
pure function sub(start: integer): list<T>

Gets a sublist from the start index to the end of the list.

pure function sub(start: integer, end: integer): list<T>

Gets a sublist from the start index (inclusive) to the end index (exclusive).

Link copied to clipboard
pure function to_text(): text

Converts the collection to a text representation.